import { postlogin } from '@/api/login'
import { Message } from 'element-ui'
const state = {
  profile: {
    adminname: '',
    role: '',
    token: '',
    checkedkeys: []
  }
}
const mutations = {
  SET_PROFILE(state, payload) {
    state.profile = payload
    // console.log(payload,'payload');
  }
}
const actions = {
  async login(context, payload) {
    let res = await postlogin(payload)
    if (res.code == 200) {
      Message({
        type: 'success',
        message: res.message
      })
      context.commit('SET_PROFILE', res.data)
      
    }
    return res
  }
}
export default { namespaced: true, state, mutations, actions }